/**
 * 
 */
package com.pi.ibean.impl;

 
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import com.pi.dao.IGpsdatainfoTbDao;
import com.pi.dao.entiy.GpsdatainfoTb;
import com.pi.ibean.IGPSDataParseBean;
 

/**
 * @author Administrator
 *
 */
public class GPSDataParseBeanImpl implements IGPSDataParseBean{

	@Resource
	private IGpsdatainfoTbDao iGpsdatainfoTbDao;
	
	@Override
	public int saveFileText(String id,List<String[]> list) {
		try {
			List<GpsdatainfoTb> listGPS = new ArrayList<GpsdatainfoTb>();
			for (String[] text : list) {
				GpsdatainfoTb gpsInfo = new GpsdatainfoTb();
				gpsInfo.setVechicleId(id);
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				ParsePosition pos = new ParsePosition(0);
				Date strtodate = formatter.parse(text[0], pos);
				gpsInfo.setTime(strtodate);
				gpsInfo.setLongitude(text[1]);
				gpsInfo.setLatitude(text[2]);
				gpsInfo.setRate(text[3]);
				gpsInfo.setDirection(text[4]);
				gpsInfo.setHeight(text[5]);
				gpsInfo.setMileage(text[6]);
				gpsInfo.setStateInfo(text[7]);
				gpsInfo.setDirectNotChage(Integer.parseInt(text[8]));
				listGPS.add(gpsInfo);
				
			}
			iGpsdatainfoTbDao.saveAll(listGPS);
			
		} catch (Exception e) {
			e.printStackTrace();
			return 1;
		}
		return 0;
	}
  

}
